package com.videri.match.client;
import java.io.Serializable;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * This class is a substitute for the java.sql.Time class
 * that is not included in the GWT.  This is a modified version
 * of the original class with a similar functionality that also
 * is serializable (in more ways than one!).
 * @author Michael Bauer
 *
 */
public class Time implements Comparable, IsSerializable, Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -3573275362550126342L;
	private long numMillis;
	
	/**
	 * Create a new time
	 */
	public Time(){
		numMillis=System.currentTimeMillis();
	}
	
	/**
	 * Create a new time with the specified number of milliseconds
	 * since January 1, 1970
	 * @param mills The time in millis
	 */
	public Time(long mills){
		numMillis = mills;
	}
	
	/**
	 * Return the time of this object
	 * @return the time stored in this object
	 */
	public long getTime(){
		return numMillis;
	}
	
	public int compareTo(Object o){
		Time t = (Time)o;
		if(numMillis<t.getTime())
			return -1;
		if(numMillis==t.getTime())
			return 0;
		return 1;
	}
}
